raar.agent
Class RAAgent

java.lang.Object
  extended by vectorimage.VectorObject
      extended by raar.world.RAWorldObject
          extended by raar.world.RAWorldObjectMovable
              extended by raar.agent.RAAgent
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
RAExternalAgent

public class RAAgent
extends RAWorldObjectMovable
implements java.io.Serializable

Overall class that brings all the process and agent stuff together. This class allows one to fully construct an agent.

See Also:
Serialized Form

Field Summary
static java.lang.String AGENT_CLASS_NAME
          Agent class name.
static int SIZE
          How large is an agent (in pixels)?
 
Fields inherited from class raar.world.RAWorldObject
SOBJ_AGENT, SOBJ_TRACE
 
Fields inherited from class vectorimage.VectorObject
OBJ_ELLIPSE, OBJ_LINE, OBJ_RECTANGLE
 
Constructor Summary
RAAgent()
          Default constructor.
RAAgent(java.util.Vector processes)
          Constructor.
RAAgent(java.util.Vector processes, boolean makeActors)
          Constructor.
 
Method Summary
 void addProcess(RAProcess p)
          Add a process.
 boolean canBeEdited()
          Return whether this agent can be edited in SB-MASE.
 boolean canBeExternal()
          Return whether this agent can be an external agent in SB-MASE.
 boolean canBeSimulated()
          Return whether this agent can be simulated in SB-MASE.
 void connect(RAProcess outputProcess, java.lang.String outputProcessRegister, RAProcess inputProcess, java.lang.String inputProcessRegister)
          Connect a specified output to a specified input.
 GVectorObject createGVectorObject()
          Create a graphical presentation.
 void disconnect(RAProcess outputProcess, java.lang.String outputProcessRegister, RAProcess inputProcess, java.lang.String inputProcessRegister)
          Disconnect a specified input from a specified output.
 void dump()
          Dump all registers of all processes to screen or file.
 RAActor getActor(java.lang.String name)
          Return the actor with the given name or null if this actor does not exist.
 java.lang.String[] getActorNames()
          Return the names of actors.
 java.awt.Color getColor()
          Return the color of this agent.
 java.util.Vector getConnections()
          Return all the connections.
 java.lang.String getName()
          Return the agent's name.
 java.util.Vector getNormalProcesses()
          Allows one to get only the normal processes.
 java.util.Vector getOtherProcesses()
          Get the non-normal processes...
 RAProcess getProcess(java.lang.String na)
          Return the process with given name.
 java.util.Vector getProcesses()
          Return the compiled processes.
 RAWorld getWorld()
          Return the world the agent is in.
 boolean isConnected()
          Return whether this agent is connected to some external source, which implies that it should not be simulated at the moment.
 boolean isEditable()
          Return whether agent is currently editable.
 void notifyAddedToWorld(RAWorld r)
          Notify this agent that it has been added to the specified world -- from now on it can request this world to move it.
 void notifyAddedToWorld(RAWorld r, java.awt.geom.Point2D.Double originalPosition, double originalRotation)
          Notify this agent that it has been added to the specified world -- from now on it can request this world to move it.
 void removeProcess(RAProcess p)
          Remove a process.
 void replaceProcess(RAProcess p, RAProcess newP)
          Replace process p by newP.
 void reset()
          Reset the agent.
 void runAgent()
          Runs the agent once.
 void setName(java.lang.String s)
          Set the agent's name.
 java.lang.String toString()
          String representation.
 
Methods inherited from class raar.world.RAWorldObjectMovable
resetPR, setPR
 
Methods inherited from class raar.world.RAWorldObject
emitsLight, getClassName, isFixed, isLight, isMassive, isMovable, isStatic, moveBy
 
Methods inherited from class vectorimage.VectorObject
contains, getBounds, getPosition, getRotation, getType, isFilled, setBounds, setPosition, setRotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

AGENT_CLASS_NAME

public static final java.lang.String AGENT_CLASS_NAME
Agent class name.

See Also:
Constant Field Values

SIZE

public static final int SIZE
How large is an agent (in pixels)?

See Also:
Constant Field Values
Constructor Detail

RAAgent

public RAAgent()
Default constructor.


RAAgent

public RAAgent(java.util.Vector processes)
Constructor. Provide processes you wish to include.


RAAgent

public RAAgent(java.util.Vector processes,
               boolean makeActors)
Constructor. Provide processes you wish to include. Say whether agent must create the SBM default actors.

Method Detail

setName

public void setName(java.lang.String s)
Set the agent's name.


getName

public java.lang.String getName()
Return the agent's name.

Overrides:
getName in class RAWorldObject

isEditable

public boolean isEditable()
Return whether agent is currently editable.


getActorNames

public java.lang.String[] getActorNames()
Return the names of actors.


getActor

public RAActor getActor(java.lang.String name)
Return the actor with the given name or null if this actor does not exist.


getColor

public java.awt.Color getColor()
Return the color of this agent.

Overrides:
getColor in class VectorObject

addProcess

public void addProcess(RAProcess p)
                throws RAException
Add a process.

Throws:
RAException

removeProcess

public void removeProcess(RAProcess p)
                   throws RAException
Remove a process.

Throws:
RAException

replaceProcess

public void replaceProcess(RAProcess p,
                           RAProcess newP)
                    throws RAException
Replace process p by newP. Connections from and to p that newP supports will be kept intact. Specify null for newP to actually just remove p and all connections from and to p.

Throws:
RAException

connect

public void connect(RAProcess outputProcess,
                    java.lang.String outputProcessRegister,
                    RAProcess inputProcess,
                    java.lang.String inputProcessRegister)
             throws RAException
Connect a specified output to a specified input. Will except if the processes do not exist in the agent, the registers do not exist in the processes, or if one of the arguments is null.

Parameters:
The - output process
The - name of the output register
The - input process
The - name of the input register
Throws:
RAException

disconnect

public void disconnect(RAProcess outputProcess,
                       java.lang.String outputProcessRegister,
                       RAProcess inputProcess,
                       java.lang.String inputProcessRegister)
Disconnect a specified input from a specified output.
This will be done by removing the RAPair from the connections list.

Parameters:
The - outputprocess
The - name of the output register
The - inputprocess
The - name of the input register

getConnections

public java.util.Vector getConnections()
Return all the connections.


notifyAddedToWorld

public void notifyAddedToWorld(RAWorld r)
Notify this agent that it has been added to the specified world -- from now on it can request this world to move it.


notifyAddedToWorld

public void notifyAddedToWorld(RAWorld r,
                               java.awt.geom.Point2D.Double originalPosition,
                               double originalRotation)
Notify this agent that it has been added to the specified world -- from now on it can request this world to move it.


getWorld

public RAWorld getWorld()
Return the world the agent is in.


reset

public void reset()
           throws RAException
Reset the agent.

Throws:
RAException

runAgent

public void runAgent()
              throws RAException
Runs the agent once. All processes will be executed parallelly, and data will be sent. After one of these runs, the agents becomes read-only to protect internal integrity. You then must reset the agent before you can edit any content.

Throws:
RAException

getProcesses

public java.util.Vector getProcesses()
Return the compiled processes.


getProcess

public RAProcess getProcess(java.lang.String na)
Return the process with given name.


dump

public void dump()
Dump all registers of all processes to screen or file.


getNormalProcesses

public java.util.Vector getNormalProcesses()
Allows one to get only the normal processes. So actors, s ensor nor inhibit/surpress are allowed.

Returns:
vector with all normal processes

getOtherProcesses

public java.util.Vector getOtherProcesses()
Get the non-normal processes...


toString

public java.lang.String toString()
String representation.

Overrides:
toString in class java.lang.Object

canBeEdited

public boolean canBeEdited()
Return whether this agent can be edited in SB-MASE.


canBeSimulated

public boolean canBeSimulated()
Return whether this agent can be simulated in SB-MASE.


canBeExternal

public boolean canBeExternal()
Return whether this agent can be an external agent in SB-MASE.


isConnected

public boolean isConnected()
Return whether this agent is connected to some external source, which implies that it should not be simulated at the moment.


createGVectorObject

public GVectorObject createGVectorObject()
Create a graphical presentation.

Overrides:
createGVectorObject in class RAWorldObject